package com.otitan.la.forest.industry.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.otitan.la.forest.industry.mapper.AssetInfoMapper;
import com.otitan.la.forest.industry.entity.AssetInfoEntity;
import com.otitan.la.forest.industry.service.AssetInfoService;
import com.otitan.webapp.framework.basepro.model.DataResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.BindingResult;

import java.util.List;

@Slf4j
@Service
public class AssetInfoServiceImpl extends ServiceImpl<AssetInfoMapper, AssetInfoEntity> implements AssetInfoService {

    @Override
    public DataResult batchDelete(List<String> ids) {
        LambdaQueryWrapper<AssetInfoEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.in(AssetInfoEntity::getEnterpriseId,ids);
        boolean isSuccess = this.remove(queryWrapper);
        log.debug("\n>>>>>>>>> 【删除资产信息表】 <<<<<<<<<\n操作结果：{}，ids：{}\n>>>>>>>>> ---- <<<<<<<<<", isSuccess, ids);
        return DataResult.success();
    }

    @Override
    public List<AssetInfoEntity> findAssets(String id) {
        LambdaQueryWrapper<AssetInfoEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(AssetInfoEntity::getEnterpriseId,id);
        List<AssetInfoEntity> assets=this.list(queryWrapper);
        return assets;
    }

}